package com.adcc.ags.gms.gw.vo;

import com.adcc.ags.gms.core.entity.GWLog;
import com.adcc.ags.gms.core.vo.BaseVO;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.util.Date;

public class GWLogVO extends BaseVO {

    // ID
    private Integer id;

    // 级别
    private String level;

    // 名称
    private String name;

    // 日志
    private String log;

    // 创建时间
    private String createTime;

    //日期结束时间
    private String dateEnd;

    //日期开始时间
    private String dateStart;

    //日志内容模糊查询关键字
    private String queryKeyword;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getLevel() {
        return level;
    }

    public void setLevel(String level) {
        this.level = level;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getLog() {
        return log;
    }

    public void setLog(String log) {
        this.log = log;
    }

    public String getCreateTime() {
        return createTime;
    }

    public void setCreateTime(String createTime) {
        this.createTime = createTime;
    }

    public String getDateEnd() {
        return dateEnd;
    }

    public void setDateEnd(String dateEnd) {
        this.dateEnd = dateEnd;
    }

    public String getDateStart() {
        return dateStart;
    }

    public void setDateStart(String dateStart) {
        this.dateStart = dateStart;
    }

    public String getQueryKeyword() {
        return queryKeyword;
    }

    public void setQueryKeyword(String queryKeyword) {
        this.queryKeyword = queryKeyword;
    }

    @Override
    public String toJson() throws JsonProcessingException {
        return new ObjectMapper().writeValueAsString(this);
    }

    @Override
    public GWLog toEntity() {
        GWLog gwLog = new GWLog();
        gwLog.setId(this.id);
        gwLog.setName(this.name);
        gwLog.setCreateTime(new Date());
        gwLog.setLevel(this.level);
        gwLog.setLog(this.log);
        return gwLog;
    }

}
